import request from '@/utils/request'

// 登录-----------------------------------------
export function login(data) {
  return request({
    url: 'login',
    method: 'post',
    data
  })
}
// 注册--------------------------------------------
export function register(data) {
  return request({
    url: 'register',
    method: 'post',
    data
  })
}
// 获取验证码
export function getCode(data) {
  return request({
    url: 'send/email',
    method: 'post',
    data
  })
}

// 验证码校验
export function verifyCode(data) {
  return request({
    url: 'verify/email',
    method: 'post',
    data
  })
}



// 视频---------------------------------------------------
// 获取视频
export function video() {
  return request({
    url: 'video',
    method: 'get',
  })
}

//点赞
export function handleLove(data) {
  return request({
    url: 'love',
    method: 'post',
    data
  })
}
//取消点赞
export function cancelLove(data) {
  return request({
    url: 'love',
    method: 'delete',
    data
  })
}


//收藏
export function handleCollect(data) {
  return request({
    url: 'collect',
    method: 'post',
    data
  })
}
//取消收藏
export function cancelCollect(data) {
  return request({
    url: 'collect',
    method: 'delete',
    data
  })
}
//分享
export function handleShare(data) {
  return request({
    url: 'share',
    method: 'post',
    data
  })
}



// 头部-----------------------------------------------------
// 搜索
export function search(data) {
  return request({
    url: 'search',
    method: 'post',
    data
  })
}


// index------------------------------------------------------
// 上传文件
export function upload(data) {
  return request({
    url: 'upload',
    method: 'post',
    data
  })
}
// 兴趣推荐--------------------------------------------

// 获取所有类别
export function getType() {
  return request({
    url: 'type',
    method: 'get',
  })
}
// 选择感兴趣的类别
export function selectType(data) {
  return request({
    url: 'type',
    method: 'put',
    data
  })
}
// 根据类别查视频
export function getTypeVideo(data) {
  return request({
    url: 'type/' + data,
    method: 'get',
  })
}

// 是否推荐感兴趣的类别
export function ifrecommend(data) {
  return request({
    url: 'recommend',
    method: 'put',
    data
  })
}

// 个人中心----------------------------------------------
// 获取用户收藏列表
export function getCollect(data) {
  return request({
    url: 'collect/u',
    method: 'post',
    data
  })
}

// 获取点赞列表
export function getLove(data) {
  return request({
    url: 'love/u',
    method: 'post',
    data
  })
}
// 获取点赞列表
export function getOwn(data) {
  return request({
    url: 'video/u',
    method: 'post',
    data
  })
}


export default {
  login, video, search, getCode, verifyCode, register, upload, getType, selectType,
  getTypeVideo, getCollect, getLove, handleLove, cancelLove, handleCollect, cancelCollect,
  handleShare, getOwn, ifrecommend
}
